package com.zrxg.kotlindemo

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(), View.OnClickListener {


    var ischjeck = false

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        // 直接赋值
        action0.text = "点我改变!"
        action0.setOnClickListener(this)
    }

    /**
     * 监听的变化
     */
    override fun onClick(p0: View?) {

        when (p0?.id) {
            R.id.action0 -> {
                if (ischjeck){
                    action0.text = "点我改变!"

                    ischjeck=false
                }else{
                    action0.text = "你好大神!"

                    ischjeck=true
                }

            }
        }
    }
}
